import { defineStore } from "pinia"
// import HYRequest from "@/services/request/index"
import { getHomeHotSuggests, getCategories, getHoustLists } from "@/services/index"

const useHomeStore = defineStore('home', {
    state: () => ({
        hotSuggests: [],
        categories: [],
        currentPage: 1,
        houseLists: []
    }),
    actions: {
        // 1.热门建议
        async fetchHotSuggestsData() {
            const res = await getHomeHotSuggests()
            console.log(res);
            this.hotSuggests = res.data
        },
        // 2.推荐类别
        async fecthCategories() {
            const res = await getCategories()
            console.log(res);
            this.categories = res.data
        },
        // 3.房屋列表
        async FetchHoustLists() {
            const res = await getHoustLists(this.currentPage);
            console.log(res);
            this.houseLists.push(...res.data)
            this.currentPage++
        }
    },
    getters: {

    }
})

export default useHomeStore